//package com.captjack.simple.application.kafka;
//
//import com.captjack.kafka.application.kafka.Constant;
//import kafka.consumer.ConsumerConfig;
//import kafka.consumer.ConsumerIterator;
//import kafka.consumer.KafkaStream;
//import kafka.javaapi.consumer.ConsumerConnector;
//
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//import java.util.Properties;
//
///**
// * Hello world!
// *
// * @author Administrator
// */
//public class TestConsumer {
//
//    public static void main(String[] args) {
//        String topic = Constant.TOPIC;
//        Properties props = new Properties();
//        props.put("zookeeper.connect", "host192:2181,host194:2181,host195:2181");
//        props.put("group.id", topic);
//        props.put("zookeeper.session.timeout.ms", "10000");
//        props.put("zookeeper.sync.time.ms", "2000");
//        props.put("auto.commit.interval.ms", "1000");
//        props.put("auto.offset.reset", "largest");
//        ConsumerConnector consumer = kafka.consumer.Consumer.createJavaConsumerConnector(new ConsumerConfig(props));
//        // 启动消费逻辑，
//        Map<String, Integer> topicCountMap = new HashMap<String, Integer>();
//        topicCountMap.put(topic, new Integer(1));
//        Map<String, List<KafkaStream<byte[], byte[]>>> consumerMap = consumer.createMessageStreams(topicCountMap);
//        KafkaStream<byte[], byte[]> stream = consumerMap.get(topic).get(0);
//        ConsumerIterator<byte[], byte[]> it = stream.iterator();
//        while (it.hasNext()) {
//            System.out.println(new String(it.next().message()));
//        }
//    }
//
//}
